package com.cooper.dao.item;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.Insert;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.Update;

import com.cooper.entity.LikeDetailEntity;

@DAO
public interface LikeDetailDAO {
	
	static final String TABLE_NAME = "d_like_detail";
	
	@ReturnGeneratedKeys
	@Insert(tableName=TABLE_NAME)
	Long saveEntity(LikeDetailEntity entity) throws Exception;
	
	@Update(tableName=TABLE_NAME, keyColumn="id")
	boolean updateEntity(LikeDetailEntity entity) throws Exception;
	
	@SQL("select * from d_like_detail t where t.deleted='n' and t.origin=:1 and t.outer_id=:2"
			+ " #if(null != :3 and '' != :3){ and client_ip=:3 } ")
	LikeDetailEntity getEntityByClientIp(String origin, Long outerId, String clientIp) throws Exception;
	
	@SQL("select * from d_like_detail t where t.deleted='n' and t.origin=:1 and t.outer_id=:2"
			+ " #if(null != :3 and '' != :3){ and user_id=:3 } ")
	LikeDetailEntity getEntityByUserId(String origin, Long outerId, Long userId) throws Exception;

}
